package com.example.sbmp;

import com.example.sbmp.user.User;
import com.example.sbmp.user.UserRepository;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author yg42117
 * @creat 2017-11-21 11:38
 * @contact yg42117@ly.com
 */
@RunWith(SpringRunner.class)
@SpringBootTest
public class Test2 {


    @Autowired
    private UserRepository userRepository;

    @Test
    public void add(){
        User mongoUser=new User();
        mongoUser.setUsername("1234");
        mongoUser.setPassword("$2a$10$Rfow1mVArIMx0MgQ6x3/RuNa/F6NAkveG/29HNiTjKk.ACaVMwXZW");
        mongoUser.setEmail("123@456.com");
        mongoUser.setLastPasswordResetDate(new Date());
        List<String> roles = new ArrayList<>();
        roles.add("ADMIN");
        roles.add("USER");
        roles.add("GUEST");
        mongoUser.setRoles(roles);
        userRepository.save(mongoUser);
    }
}
